package biz

import (
	"micros/queue"
	"micros/server"
)

type Hero struct {
	server.XEntity `micros:"embedded"`
	Name           string `sql:"size:255"`
	Status         bool
}

func (p Hero) Echo() string {
	return "hero"
}

func CreateHero(name string) *Hero {
	hero := &Hero{Name: name}
	hero.InitTime()
	hero.Parent = *hero
	hero.Create()
	queue.Trigger("test", []byte("create hero"), 0)
	return hero
}

func GetHero(ID int64) *Hero {
	hero := &Hero{}
	server.GetByID(hero.Echo(), ID, hero)
	if hero.ID == ID {
		hero.Parent = hero
	}
	return hero
}
